﻿; (function (window, undefined, $) {

    $(document).ready(function () {
        var gridopt = {
            url: options.listUrl,
            colModel: [
                    { display: '编号', name: 'Id', width: "3%", sortable: true, hide: true, align: 'left', iskey: true },
                    { display: '会员名', name: 'Name', width: "6%", sortable: false, align: 'left' },
                    { display: '公司名称', name: 'CompanyName', width: "10%", sortable: false, align: 'left' },
                    { display: '注册资本(元)', name: 'Registercapital', width: "8%", sortable: false, align: 'left' },
                    { display: '公司经营地址', name: 'ManageAdree', width: "20%", sortable: false, align: 'left' },
                    { display: '法人代表', name: 'Corporate', width: "6%", sortable: true, hide: false, align: 'left' },
                    { display: '法人代表省份证号', name: 'CorporateIDCard', width: "10%", sortable: false, align: 'left' },
                    { display: '法人代表手机号', name: 'CorporateTel', width: "8%", sortable: false, align: 'left' },
                    { display: '联系人姓名', name: 'MemberName', width: "6%", sortable: false, align: 'left' },
                    { display: '联系人手机号', name: 'MemberTel', width: "8%", sortable: false, align: 'left' },
                    { display: '审核状态', name: 'Status', width: "5%", sortable: false, align: 'center', process: companyStatus },
                    { display: '会员id', name: 'MemberId', width: "5%", sortable: false, hide: true, align: 'center', process: companyStatus },
                    { display: '操作', name: 'Id', width: "10%", sortable: false, align: 'center', process: processOp }
            ],
            sortname: "Id",
            sortorder: "DESC",
            title: false,
            rp: 15,
            usepager: true,
            showcheckbox: false
        };
        var xjgrid = new xjGrid("gridlist", gridopt);
        function processOp(value, cell) {
            var ops = [];
            if (cell[10] == 1) {
                ops.push("&nbsp;<a title='审核' href='javascript:;'  onclick=\"util.Check('", cell[11], "')\"><i class='fa fa-edit' ></i>审核</a>");
            } else {
                ops.push("&nbsp;<a title='查看' href='javascript:;'  onclick=\"util.Check('", cell[11], "')\"><i class='fa fa-edit' ></i>查看</a>");
            }

            return ops.join("");
        }
        //审核状态
        function companyStatus(value, cell) {
            if (value == 0) {
                return '未认证';
            } else if (value == 1) {
                return '审核中';
            } else if (value == 2) {
                return '已认证';
            } else {
                return '未通过';
            }
        }


        $("#formMember").submit(function () {
            xjgrid.Query(this);
            return false;
        });


        $("#btnSearch").click(function () {
            $("#formMember").submit();
        });

        util.Check = function (memberId) {
            var url = "../Company/CompanyCheck?id=" + memberId;
            location.href = url;
        };
    });

})(window, undefined, jQuery);